package com.longge;

public class DiagonalSum {

    public int diagonalSum(int[][] mat) {

        int ans = 0;
        for (int i = 0,j=mat.length-1; i < mat.length;) {
            ans+=mat[i][i];
            ans+=mat[i][j];
            i++;
            j--;
        }

        if (mat.length%2==1){
            int i = mat.length/2;
            ans-=mat[i][i];
        }
        return ans;
    }
}
